export function getExtName(fileName) {
  if (!fileName) {
    return undefined
  }

  const idx = fileName.lastIndexOf('.')
  if (idx > 0) {
    return fileName.substr(idx + 1).toLowerCase()
  }

  return undefined
}

export function checkExtName(fileName, types) {
  if (!types || types.length <= 0) {
    return false
  }

  const extName = getExtName(fileName)
  if (!extName) {
    return false
  }

  const type = types.find(type => {
    return type === extName
  })

  if (type) {
    return true
  }

  return false
}
